import { Base64 } from "js-base64";
import CryptoJS from "crypto-js";
import moment from "moment";

const OSSConfig = {
	OSS_HOST: "http://dd-eco-ai-picture.oss-cn-hangzhou.aliyuncs.com",
	OSS_ACCESS_KEY_ID: "LTAI4FsHP1pFfRXo49RnmeKP",
	OSS_ACCESS_SECRET: "FVFxlJ7dTXXwnlGDpLBxJztwJ7a2pK",
	OSS_BUCKET_NAME: "dd-eco-ai-picture",
	OSS_TODAY_KEY: moment().format("YYYYMMDD"),
	policyBase64: Base64.encode(
		JSON.stringify({
			expiration: "2028-01-01T12:00:00.000Z", // 设置该Policy的失效时间，
			conditions: [
				["content-length-range", 0, 1048576000], // 设置上传文件的大小限制
			],
		})
	),
};

const OSSBytes = {
	bytes: CryptoJS.HmacSHA1(
		OSSConfig.policyBase64,
		OSSConfig.OSS_ACCESS_SECRET,
		{
			asBytes: true,
		}
	),
};

const OSSigna = {
	signature: OSSBytes.bytes.toString(CryptoJS.enc.Base64),
};
//权限角色未配置

export { OSSConfig, OSSigna };
